/**
 * 求职招聘
 * @author Qasim <15750783791@163.com>
 * @version 2016/9/6
 */
var self = '';

var index = 1;

document.addEventListener('plusready' , ready ,  false);

function ready(){
	
	self = plus.webview.currentWebview(); 
	
 	//加载数据
 	info();
 	
 	
 	//搜索
 	$('.search').on('click' , function(){
 		search(28); 
 	})
 	 
}
 

function info(type){   
	
	plus.nativeUI.showWaiting('加载中...');
	
	$.ajax({  
		
		type:"post",
		
		url: apiRoot + '/Home/Article/info/' ,
		
		data:{
			
			tid : 28 ,
			 
			page :  index , 
			
			type : type 
			
		}, 
		
		dataType : 'json',
		
		success : function(data){ 
			
			plus.nativeUI.closeWaiting();
			 
			if(data != ''){    
				
				if(type){$('.lists').html('');}else {++index;};
				
				$.each(data , function(k , v) {  
					var html = 	'<li data-phone="'+v.phone+'" data-contacts="'+v.contacts+'" data-id="'+v.id+'" data-tid="'+v.tid+'" data-company="'+v.company_name+'" class="table-view-cell background-w overflow-h home-list home-list-2 margin-bottom-5">';
						html +=	'<div class="mui-pull-right"><div class=""><span class="mui-ellipsis-2 font-15 line-h-23 title">'+v.title+'</span><div class="content" style="display:none">'+v.body+'</div>';
						html +=	'<p class="font-14 color-c"><span>'+v.name+'</span></p><span class="font-14 color-c addtime">'+v.addtime+'</span></div></div><div class="mui-pull-left"><img src="'+getImgUrl(v.litpic)+'"/></div></li>';
					$('.lists').append(html)
				}); 
				$('.lists li').unbind();
				$('.lists li').on('click' , function(){
//					console.log(id + ',' + tid + ',' + title +',' + addtime +',' + salary +',' + company +',' + education +' ,' + number +', ' + experience +' ,' + contacts +',' +address + ','+ body);
					plus.nativeUI.showWaiting('跳转中...');
					var yqhc_inf = plus.webview.create('yqhc-inf.html' , 'yqhc-inf' , {} , { 
						
						aid : $(this).attr('data-id') , 
						tid : $(this).attr('data-tid'),
						pic : $(this).find('img').attr('src'),
						title : $(this).find('.title').text(),
						addtime : $(this).find('.addtime').text(),
						company : $(this).attr('data-company'),
						contacts : $(this).attr('data-contacts'),
						phone : $(this).attr('data-phone'),
						body : $(this).find('.content').html()

					});
					yqhc_inf.addEventListener('loaded' , function(){
						yqhc_inf.show('slide-in-right');
						plus.nativeUI.closeWaiting();
					})
				})
			}else{
				toast('没有更多的数据'); 
			}
			
		}, 
		
		error : function(e){ 
			
			plus.nativeUI.closeWaiting();
			
			toast('连接超时,请检查网络');
			
			alert(JSON.stringify(e))
			
		} 
	});
}
